#include <iostream>
#include <vector>
using namespace std;
vector<int> distributeCandies(int candies, int num_people) {
    vector<int> cur(num_people, 0);
    while (candies > 0)
    {
        for (int n = 0; n < cur.size(); n++)
        {
            if (n == 0 && cur[0] == 0)
            {
                cur[0] = 1;
                candies -= 1;
            }
            else
            {
                int m = cur[n - 1] + 1;
                if (n == 0)
                {
                    m = cur[cur.size() - 1] + 1;
                }
                if (candies < m)
                {
                    cur[n] += candies;
                    candies = 0;
                    break;
                }
                cur[n] += m;
                candies -= cur[n];
            }
        }
    }
    return cur;
}
int  main()
{
    distributeCandies(10, 3);
}